package com.qingxin.park.entity;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.GenericGenerator;

/**
 * 物资分类
 */
@Entity
@Table(name = "material_type")
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class MaterialType extends com.qingxin.sys.entity.BaseEntity implements
		java.io.Serializable {
	private static final long serialVersionUID = -3003167847693403579L;
	// Fields
	private String typeid;
	private String pid;
	private String typeCode;
	private String typeName;
	private String remark;
	private Integer typeKind;//类别：1肥料类、2植保类、3其他类
	private Set<Material> materials = new HashSet<>(0);

	// Constructors

	/** default constructor */
	public MaterialType(String typeid) {
		this.typeid = typeid;
	}
	
	public MaterialType() {
	
	}
	
	public MaterialType(String typeid, String typeCode, String typeName, Integer typeKind) {
		this.typeid = typeid;
		this.typeCode = typeCode;
		this.typeName = typeName;
		this.typeKind = typeKind;
	}

	/*typeCode,typeName,pid*/
	
	

	/** full constructor */
	public MaterialType(String pid, String typeCode, String typeName,
			String remark, Integer typeKind, Set<Material> materials) {
		this.pid = pid;
		this.typeCode = typeCode;
		this.typeName = typeName;
		this.remark = remark;
		this.typeKind = typeKind;
		this.materials = materials;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "typeid", unique = true, nullable = false, length = 32)
	public String getTypeid() {
		return this.typeid;
	}

	public void setTypeid(String typeid) {
		this.typeid = typeid;
	}

	@Column(name = "pid", length = 32)
	public String getPid() {
		return this.pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	@Column(name = "type_code", nullable = false, length = 20)
	public String getTypeCode() {
		return this.typeCode;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	@Column(name = "type_name", nullable = false, length = 50)
	public String getTypeName() {
		return this.typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	@Column(name = "remark", length = 1000)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	
	@Column(name = "type_kind")
	public Integer getTypeKind() {
		return typeKind;
	}

	public void setTypeKind(Integer typeKind) {
		this.typeKind = typeKind;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "materialType")
	@JsonIgnore
	public Set<Material> getMaterials() {
		return this.materials;
	}

	public void setMaterials(Set<Material> materials) {
		this.materials = materials;
	}

}